{% assign sidebar = site.data.sidebars[page.sidebar].entries %}

<ul id="mysidebar" class="nav">
  <li class="sidebarTitle">
    <label for="docVersion">{{sidebar[0].product}} version:</label>
    <div class="select-wrapper">
      <select id="docVersion" name="docVersion">
        {% for docV in site.docVersions %}
        <option value="{{docV.basePath}}">{{docV.label}}</option>
        {% endfor %}
      </select>
    </div>
    <div id="dev-warning">
      {% include important.html content="This documentation reflects the latest 'development'. You might want to choose a released version."
        additionalStyle="font-size:0.6em" %}
    </div>
  </li>
  {% for entry in sidebar %}
  {% for folder in entry.folders %}
  {% if folder.output contains "web" %}
    {% if folder.external_url %}
    <li><a href="{{folder.external_url}}" target="_blank">{{folder.title}}</a></li>
    {% elsif page.url == folder.url %}
    <li class="active"><a href="{{folder.url | remove: "/"}}">{{folder.title}}</a></li>
    {% elsif folder.url %}
    <li><a href="{{folder.url | remove: "/"}}">{{folder.title}}</a></li>
    {% elsif folder.type == "empty" %}
    <li><a href="{{folder.url | remove: "/"}}">{{folder.title}}</a></li>
    {% else %}
        <li class="subfolders">
          <a href="#"><span></span>{{ folder.title }}</a>
          <ul>
              {% for folderitem in folder.folderitems %}
              {% if folderitem.output contains "web" %}
              {% if folderitem.external_url %}
              <li><a href="{{folderitem.external_url}}" target="_blank">{{folderitem.title}}</a></li>
              {% elsif page.url == folderitem.url %}
              <li class="active"><a href="{{folderitem.url | remove: "/"}}">{{folderitem.title}}</a></li>
              {% elsif folderitem.type == "empty" %}
              <li><a href="{{folderitem.url | remove: "/"}}">{{folderitem.title}}</a></li>

              {% else %}
              <li><a href="{{folderitem.url | remove: "/"}}">{{folderitem.title}}</a></li>
              {% endif %}
              {% for subfolders in folderitem.subfolders %}
              {% if subfolders.output contains "web" %}
              <li class="subfolders">
                  <a href="#"><span></span>{{ subfolders.title }}</a>
                  <ul>
                      {% for subfolderitem in subfolders.subfolderitems %}
                      {% if subfolderitem.output contains "web" %}
                      {% if subfolderitem.external_url %}
                      <li><a href="{{subfolderitem.external_url}}" target="_blank">{{subfolderitem.title}}</a></li>
                      {% elsif page.url == subfolderitem.url %}
                      <li class="active"><a href="{{subfolderitem.url | remove: "/"}}">{{subfolderitem.title}}</a></li>
                      {% else %}
                      <li><a href="{{subfolderitem.url | remove: "/"}}">{{subfolderitem.title}}</a></li>
                      {% endif %}
                      {% endif %}
                      {% endfor %}
                  </ul>
              </li>
              {% endif %}
              {% endfor %}
              {% endif %}
              {% endfor %}
          </ul>
        </li>
    {% endif %}
  {% endif %}
  {% endfor %}
  {% endfor %}
    {% if sidebar[0].product %}
         <p class="external">
             <a href="#" id="collapseAll">Collapse All</a> | <a href="#" id="expandAll">Expand All</a>
         </p>
    {% endif %}
</ul>

<!-- this highlights the active parent class in the sidebar. this is critical so that the parent expands when you're viewing a page. This must appear below the sidebar code above. Otherwise, if placed inside customscripts.js, the script runs before the sidebar code runs and the class never gets inserted.-->
<script>$("li.active").parents('li').toggleClass("active");
</script>
